use tokio::time::{sleep, Duration};

pub fn task_qc() {
    println!("qc");
}

pub fn task_sy() {
    println!("sy");
}

pub fn task_cy() {
    println!("cy");
}

pub async fn task_demo2() {
    loop {
        task_qc();
        task_sy();
        task_cy();
        sleep(Duration::from_secs(1)).await;
    }
}

pub fn task_js() {
    println!("js-");
}

pub fn task_zf() {
    println!("zf-");
}

pub fn task_xs() {
    println!("xs-");
}

pub async fn task_demo3() {
    loop {
        task_js();
        task_zf();
        task_xs();
        sleep(Duration::from_secs(5)).await;
    }
}

pub async fn task_demo4() {
    // 创建异步任务
    let handle1 = tokio::spawn(task_demo2());
    let handle2 = tokio::spawn(task_demo3());

    // 等待所有任务完成
    let _ = handle1.await;
    let _ = handle2.await;
    println!("await server all =>  ok");
}
